<template>
  <div>
    <!-- 筛选条件 -->
    <el-form style="margin: 10px; padding: 10px" ref="form" size="mini" :inline="true" :model="selectdata"
      label-width="90px">
      <el-form-item label="产品渠道">
        <el-select clearable style="width: 200px" size="mini" v-model="selectdata.issueType" placeholder="请选择">
          <el-option v-for="item in ProductchannelsList" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="产品途径"> 
        <el-select clearable size="mini" v-model="selectdata.issueMethed" placeholder="请选择">
          <el-option v-for="item in ProductapproachList" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="销售渠道">
        <el-select clearable size="mini" v-model="selectdata.salesType" placeholder="请选择">
          <el-option v-for="item in channelDistribution" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="航司">
        <el-select clearable size="mini" v-model="selectdata.airCode" placeholder="请选择">
          <el-option v-for="item in airportLists" :key="item.airlinerId" :label="item.airliner"
            :value="item.airlinerId">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="舱位">
        <el-input clearable style="width: 200px" v-model="selectdata.cabin"></el-input>
      </el-form-item>
      <el-form-item label="旅客类型">
        <el-select clearable size="mini" v-model="selectdata.guestType" placeholder="请选择">
          <el-option v-for="item in travellerList" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="出发地">
        <el-input style="width: 200px" v-model="selectdata.departure"></el-input>
      </el-form-item>
      <el-form-item label="到达地">
        <el-input style="width: 200px" v-model="selectdata.arrival"></el-input>
      </el-form-item>
      <el-form-item label="政策编号">
        <el-input style="width: 200px"  v-model="selectdata.policyId"></el-input>
      </el-form-item>
      <el-form-item label="启用状态:">
        <el-radio v-model="selectdata.isUse" label=2>启用</el-radio>
        <el-radio v-model="selectdata.isUse" label=1>未启用</el-radio>
      </el-form-item>
      <el-button size="mini" type="primary" @click="searchBtn">查询</el-button>
      <el-button size="mini" type="primary" @click="addDialogVisible = true">添加</el-button>
    </el-form>
    <!-- 列表区域 -->
    <el-table :header-cell-style="{
        color: '#fff',
        background: '#6090EC',
        fontSize: '11px',
        fontWeight: 'normal',
      }" id="tableTop" :data="salespolicyList" border stripe size="mini">
      <el-table-column label="政策编号" prop="policyId"></el-table-column>
      <el-table-column label="产品渠道" prop="issueType">
        <template slot-scope="scope">
          <template v-if="scope.row.issueType == ''">全部</template>
          <template v-if="scope.row.issueType == 'BSP'">BSP</template>
          <template v-if="scope.row.issueType == 'B2B'">B2B</template>
          <template v-if="scope.row.issueType == 'OtherBuy'">外购</template>
          <template v-if="scope.row.issueType == 'LinkAirline'">航空直连</template>
          <template v-if="scope.row.issueType == 'Agreement'">三方协议</template>
          <template v-if="scope.row.issueType == 'SelfSurpport'">自营</template>
        </template>
      </el-table-column>
      <el-table-column label="产品途径" prop="issueMethed">
        <template slot-scope="scope">
          <template v-if="scope.row.issueMethed == ''">全部</template>
          <template v-if="scope.row.issueMethed == 'LinkStar'">航信</template>
          <template v-if="scope.row.issueMethed == 'Dove'">德付通</template>
          <template v-if="scope.row.issueMethed == 'Huifu'">汇付天下出票</template>
          <template v-if="scope.row.issueMethed == 'Yeebao'">易宝出票</template>
          <template v-if="scope.row.issueMethed == 'G5'">华夏</template>
          <template v-if="scope.row.issueMethed == 'DR'">瑞丽</template>
          <template v-if="scope.row.issueMethed == 'Spring'">春秋</template>
          <template v-if="scope.row.issueMethed == 'Hangbanguanjia'">航班管家
          </template>
          <template v-if="scope.row.issueMethed == 'Qunar'">去哪儿</template>
        </template>
      </el-table-column>
      <el-table-column label="销售渠道" prop="salesType">
        <template slot-scope="scope">
          <template v-if="scope.row.salesType == ''">无</template>
          <template v-if="scope.row.salesType == 'Telephone'">电话</template>
          <template v-if="scope.row.salesType == 'Online'">网上</template>
          <template v-if="scope.row.salesType == 'Phone'">手机</template>
          <template v-if="scope.row.salesType == 'Wap'">Wap</template>
        </template>
      </el-table-column>
      <el-table-column label="航司" prop="airCode"></el-table-column>
      <el-table-column label="舱位" prop="cabin"></el-table-column>
      <el-table-column label="旅客类型" prop="guestType">
        <template slot-scope="scope">
          <template v-if="scope.row.guestType == 'Adults'">成人</template>
          <template v-if="scope.row.guestType == 'Children'">儿童</template>
          <template v-if="scope.row.guestType == 'Infants'">婴儿</template>
        </template>
      </el-table-column>
      <el-table-column label="出发地" prop="departure"></el-table-column>
      <el-table-column label="到达地" prop="arrival"></el-table-column>
      <el-table-column label="产品类型" prop="productType">
        <template slot-scope="scope">
          <template v-if="scope.row.productType == '0,1'">普通产品，旗舰产品</template>
          <template v-if="scope.row.productType == '0'">普通产品</template>
          <template v-if="scope.row.productType == '1'">旗舰产品</template>
        </template>
      </el-table-column>
      <el-table-column label="代理佣金" prop="amountAgent"></el-table-column>
      <el-table-column label="加价佣金" prop="amountAdd"></el-table-column>
      <el-table-column label="后返佣金" prop="amountReturn"></el-table-column>
      <el-table-column label="是否比价差价" prop="isThan">
        <template slot-scope="scope">
          <template v-if="scope.row.isThan == 0">否</template>
          <template v-if="scope.row.isThan == 1">是</template>
        </template></el-table-column>
      <el-table-column label="政策开始时间" prop="policyDateStart"></el-table-column>
      <el-table-column label="政策结束时间" prop="policyDateEnd"></el-table-column>
      <el-table-column label="维护人" prop="employeeId"></el-table-column>
      <el-table-column label="维护时间" prop="operationTime"></el-table-column>
      <el-table-column label="创建时间" prop="createTime"></el-table-column>
      <el-table-column label="启用状态" prop="isUse">
        <template slot-scope="scope">
          <template v-if="scope.row.isUse == 0">否</template>
          <template v-if="scope.row.isUse == 1">是</template>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="180px">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="editsalrpolicy(scope.row)">
            修改
          </el-button>
          <el-button type="primary" size="mini" @click="delsalrpolicy(scope.row)">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
      :page-sizes="[10, 15, 20]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
      :total="pageTotal">
    </el-pagination>
    <!-- 新增 -->
    <el-dialog title="添加" :close-on-click-modal="false" :visible.sync="addDialogVisible" width="70%" center>
      <el-form style="margin: 10px; padding: 10px" ref="form" size="mini" :inline="true" :model="adddata"
        :rules="rulesLst" label-width="110px">
        <el-form-item label="产品渠道">
          <el-select style="width: 200px" size="mini" v-model="adddata.issueType" placeholder="请选择" clearable>
            <el-option v-for="item in ProductchannelsList" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品途径">
          <el-select size="mini" v-model="adddata.issueMethed" placeholder="请选择" clearable>
            <el-option v-for="item in ProductapproachList" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="销售渠道">
          <el-select size="mini" v-model="adddata.salesType" placeholder="请选择" clearable>
            <el-option v-for="item in channelDistribution" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="旅客类型"> 
          <el-select size="mini" v-model="adddata.guestType" placeholder="请选择" clearable>
            <el-option v-for="item in travellerList" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="航司">
          <el-select clearable size="mini" v-model="adddata.airCode" placeholder="请选择">
            <el-option v-for="item in airportLists" :key="item.airlinerId" :label="item.airliner"
              :value="item.airlinerId">
            </el-option>
          </el-select>
        </el-form-item>
 
        <el-form-item label="舱位">
          <el-input style="width: 200px" v-model="adddata.cabin"></el-input>
        </el-form-item>
        <el-form-item label="出发地">
          <el-input style="width: 200px" v-model="adddata.departure"></el-input>
        </el-form-item>
        <el-form-item label="到达地">
          <el-input style="width: 200px" v-model="adddata.arrival"></el-input>
        </el-form-item>
        <el-form-item label="政策开始时间">
          <el-date-picker v-model="adddata.policyDateStart" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="政策结束时间">
          <el-date-picker v-model="adddata.policyDateEnd" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="航班开始时间">
          <el-date-picker v-model="adddata.flightDataStart" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="航班结束时间">
          <el-date-picker v-model="adddata.flightDataEnd" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="产品类型及政策" style="margin-right: 200px">
          <el-checkbox-group v-model="adddata.productType">
            <el-checkbox label="0">普通产品</el-checkbox>
            <el-checkbox label="1">旗舰店产品</el-checkbox>
          </el-checkbox-group>
        </el-form-item>

        <el-form-item>
          <el-checkbox v-model="adddata.isUse">是否启用</el-checkbox>
        </el-form-item>
        <el-form-item label="加价佣金：">
          <el-input size="mini" v-model="adddata.amountAdd"></el-input>
        </el-form-item>
        <el-form-item label="代理佣金：">
          <el-input size="mini" v-model="adddata.amountAgent"></el-input>
        </el-form-item>
        <el-form-item label="后返佣金：">
          <el-input size="mini" v-model="adddata.amountReturn"></el-input>
        </el-form-item>
         <el-form-item>
          <el-checkbox v-model="adddata.isThan">是否比价差价</el-checkbox>
        </el-form-item>
      </el-form>
      <div style="color: red; font-size: 13px; margin-left: 30px">
        注：
        <span>1.所有字段均为必填项，没有佣金请填写默认值0.00</span><br />
        <span>2.舱位、出发地、到达地只能输入大写字母，舱位多个用英文逗号(',')隔开，如机场三字码：PEK，舱位：A,V。ALL代表全部</span>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addDialogVisible = false" size="mini">取 消</el-button>
        <el-button type="primary" size="mini" @click="getaddsalespolicy('adddata')">保 存</el-button>
      </span>
    </el-dialog>
    <!-- 删除 -->
    <el-dialog title="确认删除" :close-on-click-modal="false" :visible.sync="delDialogVisible" width="30%" center>
      <span>确认删除此条销售政策吗</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="delDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="getdeletesalespolicy()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 修改 -->
    <el-dialog title="修改" :close-on-click-modal="false" :visible.sync="editDialogVisible" width="70%" center>
      <el-form style="margin: 10px; padding: 10px" ref="editdata" size="mini" :inline="true" :model="editdata"
        label-width="110px" :rules="rules">
        <el-form-item label="产品渠道" prop="issueType">
          <el-select style="width: 200px" size="mini" v-model="editdata.issueType" placeholder="请选择" clearable>
            <el-option v-for="item in ProductchannelsList" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品途径" prop="issueMethed">
          <el-select size="mini" v-model="editdata.issueMethed" placeholder="请选择" clearable>
            <el-option v-for="item in ProductapproachList" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="销售渠道" prop="salesType">
          <el-select size="mini" v-model="editdata.salesType" placeholder="请选择" clearable>
            <el-option v-for="item in channelDistribution" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="旅客类型" prop="guestType">
          <el-select size="mini" v-model="editdata.guestType" placeholder="请选择" clearable>
            <el-option v-for="item in travellerList" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="航司" prop="airCode">
          <el-select size="mini" v-model="editdata.airCode" placeholder="请选择" clearable>
            <el-option v-for="item in airportLists" :key="item.airlinerId" :label="item.airliner"
              :value="item.airlinerId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="舱位" prop="cabin">
          <el-input style="width: 200px" v-model="editdata.cabin"></el-input>
        </el-form-item>

        <el-form-item label="出发地" prop="departure">
          <el-input style="width: 200px" v-model="editdata.departure"></el-input>
        </el-form-item>
        <el-form-item label="到达地" prop="arrival">
          <el-input style="width: 200px" v-model="editdata.arrival"></el-input>
        </el-form-item>
        <el-form-item label="政策开始时间" prop="policyDateStart">
          <el-date-picker v-model="editdata.policyDateStart" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="政策结束时间" prop="policyDateEnd">
          <el-date-picker v-model="editdata.policyDateEnd" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="航班开始时间" prop="flightDataStart">
          <el-date-picker v-model="editdata.flightDataStart" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="航班结束时间" prop="flightDataEnd">
          <el-date-picker v-model="editdata.flightDataEnd" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="产品类型及政策" style="margin-right: 200px">
          <el-checkbox-group v-model="editdata.productType">
            <el-checkbox label="0">普通产品</el-checkbox>
            <el-checkbox label="1">旗舰店产品</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item>
          <el-checkbox v-model="editdata.isUse">是否启用</el-checkbox>
        </el-form-item>
        <el-form-item label="加价佣金：" prop="amountAdd">
          <el-input size="mini" v-model="editdata.amountAdd"></el-input>
        </el-form-item>
        <el-form-item label="代理佣金：">
          <el-input size="mini" v-model="editdata.amountAgent"></el-input>
        </el-form-item>
        <el-form-item label="后返佣金：">
          <el-input size="mini" v-model="editdata.amountReturn"></el-input>
        </el-form-item>
         <el-form-item>
          <el-checkbox v-model="editdata.isThan">是否比价差价</el-checkbox>
        </el-form-item>
      </el-form>
      <div style="color: red; font-size: 13px; margin-left: 30px">
        注：
        <span>1.所有字段均为必填项，没有佣金请填写默认值0.00</span><br />
        <span>2.舱位、出发地、到达地只能输入大写字母，舱位多个用英文逗号(',')隔开，如机场三字码：PEK，舱位：A,V。ALL代表全部</span>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editDialogVisible = false" size="mini">取 消</el-button>
        <el-button type="primary" size="mini" @click="geteditsalespolicy()">保 存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        form: {},
        value1: "",
        value: "",
        TicketRemindList: [],
        checked: "",

        //  查,询列表数据
        selectdata: {
          policyId: "", //销售政策基本信息ID
          issueType: "", //产品渠道
          issueMethed: "", //产品途径
          salesType: "", //销售渠道
          guestType: "", //旅客类型
          airCode: "", //航空公司编码
          cabin: "", //舱位
          departure: "", //出发地
          arrival: "", //到达地
        isUse: null, //是否启用（0否1是）
        },
        //查询回来的数据
        salespolicyList: [],

        // 新增政策数据
        adddata: {
          issueType: "", //产品渠道
          issueMethed: "", //产品途径
          salesType: "", //销售渠道
          guestType: "", //乘客类型
          airCode: "", //航空公司编码
          cabin: "", //舱位（多个以逗号隔开）
          departure: "", //出发地
          arrival: "", //到达地
          policyDateStart: "", //政策开始时间
          policyDateEnd: "", //政策结束时间
          flightDataStart: "", //航班开始时间
          flightDataEnd: "", //航班结束时间
          productType: [], //产品类型及政策（多个以逗号隔开：0普通产品1旗舰店产品）
          amountAgent: "", //代理佣金
          amountReturn: "", //后返佣金
          amountAdd: "", //加价佣金
          isSuit: "", //是否适用最低价
          isMatching: "", //是否匹配原退改签
          isThan: "", //是否比价差价
          isUse: null, //是否启用
          isThan:null,
          amountAgent:null,
          amountReturn:null,
        },
        // 修改验证
        rules: {
          issueType: [{
            required: true,
            message: "请选择产品渠道",
            trigger: "change"
          }, ],
          issueMethed: [{
            required: true,
            message: "请选择产品途径",
            trigger: "change"
          }, ],
          salesType: [{
            required: true,
            message: "请选择销售渠道",
            trigger: "change"
          }, ],
          guestType: [{
            required: true,
            message: "乘客类型",
            trigger: "change"
          }],
          airCode: [{
            required: true,
            message: "航空公司编码",
            trigger: "change"
          }, ],
          cabin: [{
            required: true,
            message: "舱位（多个以逗号隔开）",
            trigger: "blur",
          }, ],
          departure: [{
            required: true,
            message: "出发地",
            trigger: "blur"
          }],
          arrival: [{
            required: true,
            message: "到达地",
            trigger: "blur"
          }],
          policyDateStart: [{
            type: "date",
            required: true,
            message: "政策开始时间",
            trigger: "change",
          }, ],
          policyDateEnd: [{
            type: "date",
            required: true,
            message: "政策结束时间",
            trigger: "change",
          }, ],
          flightDataStart: [{
            type: "date",
            required: true,
            message: "航班开始时间",
            trigger: "change",
          }, ],
          flightDataEnd: [{
            type: "date",
            required: true,
            message: "航班结束时间",
            trigger: "change",
          }, ],
          amountAdd: [{
            required: true,
            message: "加价佣金",
            trigger: "blur"
          }],
        },
        // 新增校验
        rulesLst: {
          issueType: [{
            required: true,
            message: "请选择产品渠道",
            trigger: "change"
          }, ],
          issueMethed: [{
            required: true,
            message: "请选择产品途径",
            trigger: "change"
          }, ],
          salesType: [{
            required: true,
            message: "请选择销售渠道",
            trigger: "change"
          }, ],
          guestType: [{
            required: true,
            message: "乘客类型",
            trigger: "change"
          }],
          airCode: [{
            required: true,
            message: "航空公司编码",
            trigger: "change"
          }, ],
          cabin: [{
            required: true,
            message: "舱位（多个以逗号隔开）",
            trigger: "blur",
          }, ],
          departure: [{
            required: true,
            message: "出发地",
            trigger: "blur"
          }],
          arrival: [{
            required: true,
            message: "到达地",
            trigger: "blur"
          }],
          policyDateStart: [{
            type: "date",
            required: true,
            message: "政策开始时间",
            trigger: "change",
          }, ],
          policyDateEnd: [{
            type: "date",
            required: true,
            message: "政策结束时间",
            trigger: "change",
          }, ],
          flightDataStart: [{
            type: "date",
            required: true,
            message: "航班开始时间",
            trigger: "change",
          }, ],
          flightDataEnd: [{
            type: "date",
            required: true,
            message: "航班结束时间",
            trigger: "change",
          }, ],
          amountAdd: [{
            required: true,
            message: "加价佣金",
            trigger: "blur"
          }],
        },
        // 修改政策数据
        editdata: {
          issueType: "", //产品渠道
          issueMethed: "", //产品途径
          salesType: "", //销售渠道
          guestType: "", //乘客类型
          airCode: "", //航空公司编码
          cabin: "", //舱位（多个以逗号隔开）
          departure: "", //出发地
          arrival: "", //到达地
          policyDateStart: "", //政策开始时间
          policyDateEnd: "", //政策结束时间
          flightDataStart: "", //航班开始时间
          flightDataEnd: "", //航班结束时间
          productType: "", //产品类型及政策（多个以逗号隔开：0普通产品1旗舰店产品）
          amountAgent: "", //代理佣金
          amountReturn: "", //后返佣金
          amountAdd: "", //加价佣金
          isSuit: "", //是否适用最低价
          isMatching: "", //是否匹配原退改签
          isThan: "", //是否比价差价
          isUse: null, //是否启用
          policyId: "",
          isThan:null,
          amountAgent:null,
          amountReturn:null,
        },
        // 删除使用id
        policyId: "",
        // 修改用的id
        editpolicyId: "",
        // 新增弹窗显示
        addDialogVisible: false,
        // 删除弹窗
        delDialogVisible: false,
        // 修海弹窗
        editDialogVisible: false,
        // 航司下拉列表
        airportLists: [],
        // 产品类型多选
        checkList: [],
        //分页
        pageSize: 10,
        currentPage: 1,
        pageTotal: 0,

        // 产品渠道下拉
        ProductchannelsList: [{
            value: "",
            label: "全部",
          },
          {
            value: "BSP",
            label: "BSP",
          },
          {
            value: "B2B",
            label: "B2B",
          },
          {
            value: "OtherBuy",
            label: "外购",
          },
          {
            value: "LinkAirline",
            label: "航空直连",
          },
          {
            value: "Agreement",
            label: "三方协议",
          },

          {
            value: "SelfSurpport",
            label: "自营",
          },
        ],
        // 销售渠道
        channelDistribution: [{
            value: "",
            label: "全部",
          },
          {
            value: "Telephone",
            label: "电话",
          },
          {
            value: "Online",
            label: "网上",
          },
          {
            value: "Phone",
            label: "手机",
          },
          {
            value: "Wap",
            label: "Wap",
          },
        ],
        // 产品途径
        ProductapproachList: [{
            value: "",
            label: "全部",
          },
          {
            value: "LinkStar",
            label: "航信",
          },
          {
            value: "Dove",
            label: "德付通",
          },
          {
            value: "Huifu",
            label: "汇付天下出票",
          },
          {
            value: "Yeebao",
            label: "易宝出票",
          },
          {
            value: "G5",
            label: "华夏",
          },
          {
            value: "DR",
            label: "瑞丽",
          },
          {
            value: "Spring",
            label: "春秋",
          },
          {
            value: "Hangbanguanjia",
            label: "航班管家",
          },
          {
            value: "Qunar",
            label: "去哪儿",
          },
        ],
        // 旅客类型
        travellerList: [{
            value: "Adults",
            label: "成人",
          },
          {
            value: "Children",
            label: "儿童",
          },
          {
            value: "Infants",
            label: "婴儿",
          },
        ],
      };
    },
    watch: {},

    methods: {
      // 修改保存验证
      // submitForm(editdata) {
      //   this.$refs[editdata].validate((valid) => {
      //     if (valid) {
      //       alert("submit!");
      //     } else {
      //       console.log("error submit!!");
      //       return false;
      //     }
      //   });
      // },
      //分页
      handleSizeChange(value) {
        console.log("1", value);
        localStorage.setItem("pageSize", value);
        localStorage.setItem("pageNum", 1);
        this.getsalespolicylist();
        this.pageSize = value;
      },
      handleCurrentChange(value) {
        console.log("2", value);
        localStorage.setItem("pageNum", value);
        localStorage.setItem("pageSize", this.pageSize);
        this.currentPage = value;
        this.getsalespolicylist();
        // orders = res.data;
      },
      searchBtn() {
        localStorage.setItem("pageNum", 1);
        localStorage.setItem("pageSize", 10);
        this.getsalespolicylist();
      },
      // 航司列表接口
      getairportList() {
        this.$axios.getqueryAirlinerSelect({}).then((res) => {
          console.log(res);
          if (res.code == "200") {
            this.airportLists = res.data;
          }
        });
      },
      // 条件查询列表
      getsalespolicylist() {
        localStorage.setItem("pageNum", this.currentPage);
        localStorage.setItem("pageSize", this.pageSize);
        this.$axios
          .getsalespolicylist({
            policyId: Number(this.selectdata.policyId), //政策基本信息ID
            issueType: this.selectdata.issueType, //政策基本信息ID
            issueMethed: this.selectdata.issueMethed, //政策基本信息ID
            salesType: this.selectdata.salesType, //政策基本信息ID
            guestType: this.selectdata.guestType, //政策基本信息ID
            airCode: this.selectdata.airCode, //政策基本信息ID
            cabin: this.selectdata.cabin, //政策基本信息ID
            departure: this.selectdata.departure, //政策基本信息ID
            arrival: this.selectdata.arrival, //政策基本信息ID
            isUse: Number(this.selectdata.isUse), //政策基本信息ID
          })
          .then((res) => {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
            console.log(res);
            // debugger
            if (res.code == "200") {
              this.salespolicyList = res.data;
              this.pageTotal = res.total;
            }        
          });
      },
      // 新增查询列表
      getaddsalespolicy() {
        // debugger
        // debugger
        console.log(this.editdata,this.adddata) 
        localStorage.setItem("isToken", true);
        if (
          this.adddata.issueType != "" &&
          this.adddata.issueMethed != "" &&
          this.adddata.salesType != "" &&
          this.adddata.guestType != "" &&
          this.adddata.airCode != "" &&
          this.adddata.cabin != "" &&
          this.adddata.departure != "" &&
          this.adddata.arrival != "" &&
          this.adddata.policyDateStart != "" &&
          this.adddata.policyDateEnd != "" &&
          this.adddata.flightDataStart != "" &&
          this.adddata.flightDataEnd != "" &&
          this.adddata.productType.length != 0 &&
          this.adddata.amountAdd != ""  
          // productType
        ) {
          if(this.adddata.isUse==true){
            this.adddata.isUse=1
          }else{
            this.adddata.isUse=0
          }
          if(this.adddata.isThan==true){
            this.adddata.isThan=1
          }else{
            this.adddata.isThan=0
          }
          let arr =''
          for(let i=0;i< this.adddata.productType.length;i++){
           arr+=this.adddata.productType[i]+','
          }
         arr= arr.substring(0, arr.lastIndexOf(','))
          console.log(arr) 
          this.$axios
            .getaddsalespolicy({
              issueType: this.adddata.issueType, //产品渠道
              issueMethed: this.adddata.issueMethed, //产品途径
              salesType: this.adddata.salesType, //销售渠道
              guestType: this.adddata.guestType, //乘客类型
              airCode: this.adddata.airCode, //航司
              cabin: this.adddata.cabin, //舱位
              departure: this.adddata.departure, //出发地
              arrival: this.adddata.arrival, //到达地
              policyDateStart: this.adddata.policyDateStart, //政策开始时间
              policyDateEnd: this.adddata.policyDateEnd, //政策结束时间
              flightDataStart: this.adddata.flightDataStart, //航班开始时间
              flightDataEnd: this.adddata.flightDataEnd, //航班结束时间
              productType: arr, //产品类型及政策
              amountAdd: this.adddata.amountAdd, //加价佣金
              isUse: this.adddata.isUse, //是否启用
              isThan: this.adddata.isThan, //是否启用
              amountReturn: this.adddata.amountReturn, //是否启用
              isUse: this.adddata.isUse, //是否启用
            })
            .then((res) => {
              console.log(res);
              // debugger
              if (res.code == "200") {
                this.addDialogVisible = false;
                this.getsalespolicylist();
                this.$message({
                  message: "新增成功",
                  type: "success",
                });
                
              }
            });
        } else {
          this.$message({
            message: "请认真填写信息,所有选项均为必填项",
          });
        }
      },
      // 删除点击事件
      delsalrpolicy(row) {
        console.log(row);
        this.delDialogVisible = true;
        this.policyId = row.policyId;
        console.log(this.policyId);
      },
      // 删除接口
      getdeletesalespolicy() {
        this.$axios
          .getdeletesalespolicy({
            policyId: this.policyId, //被删除的id
          })
          .then((res) => {
            console.log(res);
            // debugger
            if (res.code == "200") {
              this.delDialogVisible = false;
              this.getsalespolicylist();
              this.$message({
                message: "删除成功",
                type: "success",
              });
            }
          });
      },
      // 修改点击事件
      editsalrpolicy(row) {
        console.log(row);
        this.editdata = row;
        console.log(this.editdata);
        this.editDialogVisible = true;
      },
      // 修改
      geteditsalespolicy() {
        if (
          this.editdata.issueType != "" &&
          this.editdata.issueMethed != "" &&
          this.editdata.salesType != "" &&
          this.editdata.guestType != "" &&
          this.editdata.airCode != "" &&
          this.editdata.cabin != "" &&
          this.editdata.departure != "" &&
          this.editdata.arrival != "" &&
          this.editdata.policyDateStart != "" &&
          this.editdata.policyDateEnd != "" &&
          this.editdata.flightDataStart != "" &&
          this.editdata.flightDataEnd != "" &&
          this.editdata.productType != "" &&
          this.editdata.amountAdd != ""
        ) {
          if(this.editdata.isThan==true){
            this.editdata.isThan=1
          }else{
            this.editdata.isThan=0
          }
          this.$axios
            .geteditsalespolicy({
              issueType: this.editdata.issueType, //产品渠道
              issueMethed: this.editdata.issueMethed, //产品途径
              salesType: this.editdata.salesType, //销售渠道
              guestType: this.editdata.guestType, //乘客类型
              airCode: this.editdata.airCode, //航司
              cabin: this.editdata.cabin, //舱位
              departure: this.editdata.departure, //出发地
              arrival: this.editdata.arrival, //到达地
              policyDateStart: this.editdata.policyDateStart, //政策开始时间
              policyDateEnd: this.editdata.policyDateEnd, //政策结束时间
              flightDataStart: this.editdata.flightDataStart, //航班开始时间
              flightDataEnd: this.editdata.flightDataEnd, //航班结束时间
              productType: this.editdata.productType, //产品类型及政策
              amountAdd: this.editdata.amountAdd, //加价佣金
              isUse: this.editdata.isUse, //是否启用
              policyId: this.editdata.policyId,
              isThan: this.editdata.isThan, //加价佣金
              amountReturn: this.editdata.amountReturn, //是否启用
              amountAgent: this.editdata.amountAgent,
            })
            .then((res) => {
              console.log(res);
              // debugger
              if (res.code == "200") {
                this.editDialogVisible = false;
                this.getsalespolicylist();
                this.$message({
                  message: "修改成功",
                  type: "success",
                });
              }
            });
        } else {
          this.$message({
            message: "请认真填写信息,所有选项均为必填项",
          });
        }
      },
    },

    mounted() {
      // 列表
      this.getairportList();
      this.getsalespolicylist();
    },
  };
</script>
<style scoped>
</style>